package com.rds.web.controller.system;

import com.rds.common.core.controller.BaseController;
import com.rds.common.core.page.TableDataInfo;
import com.rds.system.domain.SysHistory;
import com.rds.system.service.ISysHistoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 历史记录-->Controller类
 * @version : 1.0
 * @Copyright: Copyright(c) 2020-2021 All right reserved
 * @Company: GUANGZHOU RDS Co.,LTD
 * @author: LiChuanlong
 * @create Date : 2021/12/13 : 23:51
 */
@RequestMapping("/pms/history")
@RestController
public class SysHistoryController extends BaseController {
    @Autowired
    private ISysHistoryService sysHistoryService;

    /**
     * 查询所有历史记录
     * @param sysHistory 历史记录对象
     * @return 历史记录数据集合
     */
    @GetMapping("/list")
    public TableDataInfo list(SysHistory sysHistory)
    {
        startPage();
        List<SysHistory> list = sysHistoryService.findHistorys(sysHistory);
        return getDataTable(list);
    }

    /**
     * 查询生命周期历史记录
     * @param sysHistory 历史记录对象
     * @return 历史记录数据集合
     */
    @GetMapping("/lifecycle")
    public TableDataInfo lifecycleHistory(SysHistory sysHistory)
    {
        startPage();
        sysHistory.setOperateScope(1);
        List<SysHistory> list = sysHistoryService.findHistorys(sysHistory);
        return getDataTable(list);
    }

    /**
     * 根据查询范围查询记录记录 0 表示查所有 1 查询生命周期历史记录 2 查询对象操作记录
     * 搜索查询用
     * @param sysHistory 历史记录对象
     * @return  历史记录数据集合
     */
    @GetMapping("/scope")
    public TableDataInfo scopeList(SysHistory sysHistory)
    {
        startPage();
        Integer scope = sysHistory.getOperateScope();
        List<SysHistory> list = sysHistoryService.selectHistoryByScope(scope);
        return getDataTable(list);
    }
}
